package com.fd.dx.web.controllers;

import com.fd.dx.domain.User;
import com.fd.dx.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LoginController {
    @Autowired
    public UserService userService;
    @RequestMapping("/login")
    public String login() {
        return "sys/login";
    }
    @RequestMapping("/sys/login")
    public String sysLogin(String username,String password,ModelMap map) {
        User user=userService.findByName(username);
        if(user!=null&&user.getPassword().equals(password))
        {
            return "redirect:/sys/index";

        }else
        {
            map.addAttribute("error","用户名密码错误！");
            return "sys/login";
        }

    }
}
